package cn.sciento.boot.tenant.feign.fallback;

import feign.hystrix.FallbackFactory;
import cn.sciento.boot.tenant.dto.TenantInitConfigDTO;
import cn.sciento.boot.tenant.dto.TenantInitLogDTO;
import cn.sciento.boot.tenant.feign.HiamFeignService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

@Component
public class HiamFeignServiceFallbackFactory implements FallbackFactory<HiamFeignService> {
  private static final Logger LOGGER = LoggerFactory.getLogger(HiamFeignServiceFallbackFactory.class);
  
  public HiamFeignService create(Throwable throwable) {
    LOGGER.error("hiam feign fallback with error: ", throwable);
    return new HiamFeignService() {
        @Override
        public TenantInitConfigDTO registerTenantInitProcessor(TenantInitConfigDTO tenantInitConfigDTO) {
          return null;
        }
        
        public void log(@RequestBody TenantInitLogDTO tenantInitLogDTO) {}
      };
  }
}
